﻿using System;
using System.Globalization;
using Newtonsoft.Json;

namespace CkSoftware.GroupMe.Sdk.Core.Dao
{
	/// <summary>
	/// GroupMe API response metadata DAO.
	/// </summary>
	public class MetaData
	{
		/// <summary>
		/// The raw GroupMe API response code.
		/// </summary>
		[JsonProperty(PropertyName = "code")]
		public int Code { get; set; }

		/// <summary>
		/// A List of error-messages which occured on the GroupMe API server. Either this or the SingleError Field is filled out if
		/// an error occured.
		/// </summary>
		[JsonProperty(PropertyName = "errors")]
		public string[] Errors { get; set; }

		/// <summary>
		/// The parsed GroupMe API result code.
		/// </summary>
		public GroupMeApiResultCode ParsedCode
		{
			get
			{
				return (GroupMeApiResultCode) Enum.Parse(typeof (GroupMeApiResultCode), Code.ToString(CultureInfo.CurrentCulture));
			}
		}

		/// <summary>
		/// A single error given by the GroupMe API. Either this or the Errors Field is filled out if an error occured.
		/// </summary>
		[JsonProperty(PropertyName = "error")]
		public string SingleError { get; set; }
	}
}